from django.shortcuts import render
from .models import OneMusicCreate
from rest_framework import mixins
from rest_framework.viewsets import GenericViewSet,ModelViewSet
from .serializers import OneMusicCreateSerializer
from utils.page_settings import LargeResultSetPagination
from rest_framework import filters
from utils.filters import MusicDetailFilter
import django_filters.rest_framework as df_filters

# Create your views here.

class MusicViewSet(mixins.ListModelMixin,GenericViewSet):
    """
    获取歌曲信息接口
    """
    queryset = OneMusicCreate.objects.all()
    serializer_class = OneMusicCreateSerializer
    pagination_class = LargeResultSetPagination
    filter_backends = (df_filters.DjangoFilterBackend, filters.OrderingFilter)
    search_fields = ('OneMusicCreate__singer', 'OneMusicCreate__song_name', 'OneMusicCreate__album')
    ordering_fields = ('id', 'add_time')
    # filter_class = MusicDetailFilter
